package org.halk.config;

import cn.hutool.core.text.StrPool;
import lombok.Data;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 节假日自定义名称
 *
 * @Author halk
 * @Date 2023/4/25 21:33
 **/
@Component
@Data
public class CustomHolidayProperties {
    /**
     * 节假日名称
     */
    private List<String> holidayNameList;


    /**
     * 传入新的值覆盖list
     *
     * @param holidayNameStr
     */
    public void coverList(String holidayNameStr) {
        if (StringUtils.hasText(holidayNameStr)) {
            this.holidayNameList = Arrays.stream(holidayNameStr.split(StrPool.COMMA)).collect(Collectors.toList());
            return;
        }
        this.holidayNameList.clear();
    }

}

